
<template>
  <div class="nofity">111</div>
</template>
<script>
import { getInfoUtilis } from "@/common/utils";
import { BASE_API } from "./common/request.js";
import Notify from "./wxcomponents/vant/notify/notify";
export default {
  globalData: {
    searchText: "",
    appVersion: {},
    config: {},
    $i18n: {},
    $t: {},
    $pxtorpx: "",
    $navigationBarHeight: "",
    $statusBarHeight: "",
    $safeTop: "",
    $windowHeight: "",
    $useHeight: "",
    $safeAreaBottom: "",
    $tabBarHeight: "",
    $screenHeight: "",
    $safeAreaInsetsTop: "",
    $lableConfig: {
      chapter: "任务",
      task: "环节",
      content: "步骤",
    },
    $url: "",
  },
  onLaunch: function () {
    console.log("App Launch");
    // 检查更新
    const updateManager = uni.getUpdateManager();
    updateManager.onCheckForUpdate(function (res) {
      console.log("检查更新");
    });

    updateManager.onUpdateReady(function (res) {
      uni.showModal({
        title: "更新提示",
        content: "新版本已经准备好，是否重启应用？",
        success(res) {
          if (res.confirm) {
            updateManager.applyUpdate();
          }
        },
      });
    });

    updateManager.onUpdateFailed(function (res) {
      console.log("新版本下载失败");
      uni.showToast({ title: "小程序更新失败", icon: "none", duration: 5000 });
    });
    getInfoUtilis();
    this.globalData.$pxtorpx = 750 / uni.getSystemInfoSync().windowWidth;
    // 获取系统信息
    uni.getSystemInfo({
      success: (res) => {
        console.log(res);
        // 导航栏高度
        this.globalData.$navigationBarHeight =
          (res.platform === "android" ? 48 : 44) * this.globalData.$pxtorpx;
        // 状态栏高度
        this.globalData.$statusBarHeight =
          res.statusBarHeight * this.globalData.$pxtorpx;
        //   除去顶部的 屏幕高度
        this.globalData.$windowHeight =
          res.windowHeight * this.globalData.$pxtorpx;
        //   除去顶部的 屏幕高度-状态栏高度-导航栏高度
        this.globalData.$useHeight =
          res.windowHeight * this.globalData.$pxtorpx -
          this.globalData.$navigationBarHeight -
          this.globalData.$statusBarHeight;
        //   底部安全距离
        this.globalData.$safeAreaBottom =
          res.screenHeight - res.safeArea.bottom;
        // tabbar高度
        this.globalData.$safeAreaInsetsTop = res.safeAreaInsets.top;
      },
    });
    console.log(this.globalData);
    this.globalData.$i18n = this.$i18n;
    this.globalData.$safeTop = parseInt(
      (uni.getSystemInfoSync().safeAreaInsets.top * 750) /
        uni.getSystemInfoSync().windowWidth
    );
    this.globalData.$i18n = this.$i18n;
    this.globalData.$t = (str) => this.$t(str);

    // #ifdef APP-PLUS
    //checkIsAgree(); APP端暂时先用原生默认生成的。目前，自定义方式启动vue界面时，原生层已经请求了部分权限这并不符合国家的法规
    // #endif

    // #ifdef H5
    // checkIsAgree(); // 默认不开启。目前全球，仅欧盟国家有网页端同意隐私权限的需要。如果需要可以自己去掉注视后生效
    // #endif

    // #ifdef APP-PLUS
    //idfa有需要的用户在应用首次启动时自己获取存储到storage中
    /*var idfa = '';
			var manager = plus.ios.invoke('ASIdentifierManager', 'sharedManager');
			if(plus.ios.invoke(manager, 'isAdvertisingTrackingEnabled')){
				var identifier = plus.ios.invoke(manager, 'advertisingIdentifier');
				idfa = plus.ios.invoke(identifier, 'UUIDString');
				plus.ios.deleteObject(identifier);
			}
			plus.ios.deleteObject(manager);
			console.log('idfa = '+idfa);*/
    // #endif
  },
  onShow: function () {
    console.log("App Show");
    if (uni.getStorageSync("token")) {
      // this.initWebSocket();
    }
  },
  onHide: function () {
    console.log("Apgit p Hide");
  },
  methods: {
    //   guid() {
    //     return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
    //       /[xy]/g,
    //       function (c) {
    //         var r = (Math.random() * 16) | 0,
    //           v = c == "x" ? r : (r & 0x3) | 0x8;
    //         return v.toString(16);
    //       }
    //     );
    //   },
    //   initWebSocket() {
    // const serverUrl = uni.getStorageSync('serverUrl');
    // let baseurl
    // if(serverUrl){
    // 	baseurl=BASE_API.split("//").splice(1).join("");
    // }else{
    // 	baseurl=serverUrl.split("//").splice(1).join("");
    // }
    //     console.log(
    //       `wss://${baseurl}/myWS?user=student-${uni.getStorageSync("userId")}-${this.guid().replace(/-/g, "")}`,"//////////////"
    //     );
    //     uni.connectSocket({
    //   // url:`ws://192.168.110.7:8002/mixedState/myWS?user=student-${uni.getStorageSync("userId")}-${this.guid().replace(/-/g, "")}`
    //    url:`wss://${baseurl}/myWS?user=student-${uni.getStorageSync("userId")}-${this.guid().replace(/-/g, "")}`
    //     });
    //     uni.onSocketOpen((res) => {
    //       console.log("WebSocket连接已打开！");
    //       // Notify({ type: "primary", message: "WebSocket连接已打开！" });
    //     });
    //     uni.onSocketMessage((res) => {
    //   console.log(res.data,"//////////////////////");
    //       console.log("收到服务器内容："+res.data);
    // if(res.data != "heartbeat"){
    // 	uni.showToast({
    // 		position:"top",
    // 		title:`${JSON.parse(res.data).content}`,
    // 		duration: 3000,
    // 		icon:"none"
    // 	});
    // }
    //       // Notify({ type: "primary", message:JSON.parse(res.data).content);
    //     });
    //     uni.onSocketError((res) => {
    //       console.log("WebSocket连接打开失败，请检查！");
    //     });
    //   },
  },
};
</script>

<style lang="scss">
@import "@/uni_modules/uni-scss/index.scss";
/*每个页面公共css */

page {
  // background: #fafafa;
  background: white;
}
.nofity{
  position: fixed;
  top: 0;
  background: pink;
}
</style>
